package org.jeecg.modules.online.cgform.utils;

import java.util.ArrayList;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.query.QueryRuleEnum;
import org.jeecg.common.system.vo.SysPermissionDataRuleModel;
import org.jeecg.modules.online.auth.p004b.AuthConstants;
import org.jeecg.modules.online.config.p022d.DataBaseConst;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/* renamed from: org.jeecg.modules.online.cgform.d.k */
/* loaded from: hibernate-re-3.7.1-RC.jar:org/jeecg/modules/online/cgform/d/k.class */
public class SuperQueryLoaderTools {

    /* renamed from: a */
    private static final Logger f346a = LoggerFactory.getLogger(SuperQueryLoaderTools.class);

    /* renamed from: a */
    public static void m275a(StringBuilder sb, QueryRuleEnum queryRuleEnum, String str, String str2, String str3) {
        if ("date".equals(str3) && "ORACLE".equalsIgnoreCase(CgformUtil.getDatabseType())) {
            String replace = str2.replace(CgformUtil.f231C, "");
            if (replace.length() == 10) {
                str2 = CgformUtil.m344b(replace);
            } else {
                str2 = CgformUtil.m378a(replace);
            }
        }
        switch (C00131.f347a[queryRuleEnum.ordinal()]) {
            case 1:
                sb.append(CgformUtil.f218p).append(str2);
                return;
            case 2:
                sb.append(CgformUtil.f217o).append(str2);
                return;
            case 3:
                sb.append(CgformUtil.f220r).append(str2);
                return;
            case AuthConstants.f111o /* 4 */:
                sb.append(CgformUtil.f219q).append(str2);
                return;
            case 5:
                sb.append(CgformUtil.f216n).append(str2);
                return;
            case 6:
                sb.append(" IN (");
                String[] split = str.split(CgformUtil.f233E);
                for (int i = 0; i < split.length; i++) {
                    String str4 = split[i];
                    if (StringUtils.isNotBlank(str4)) {
                        sb.append(m279a(str3, str4));
                        if (i < split.length - 1) {
                            sb.append(CgformUtil.f233E);
                        }
                    }
                }
                sb.append(")");
                return;
            case 7:
                sb.append(CgformUtil.f208f).append("N").append(CgformUtil.f231C).append("%").append(str).append("%").append(CgformUtil.f231C);
                return;
            case 8:
                sb.append(CgformUtil.f208f).append("N").append(CgformUtil.f231C).append("%").append(str).append(CgformUtil.f231C);
                return;
            case 9:
                sb.append(CgformUtil.f208f).append("N").append(CgformUtil.f231C).append(str).append("%").append(CgformUtil.f231C);
                return;
            case 10:
            default:
                sb.append(CgformUtil.f215m).append(str2);
                return;
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* compiled from: SuperQueryLoaderTools.java */
    /* renamed from: org.jeecg.modules.online.cgform.d.k$1 */
    /* loaded from: hibernate-re-3.7.1-RC.jar:org/jeecg/modules/online/cgform/d/k$1.class */
    public static /* synthetic */ class C00131 {

        /* renamed from: a */
        static final /* synthetic */ int[] f347a = new int[QueryRuleEnum.values().length];

        static {
            try {
                f347a[QueryRuleEnum.GT.ordinal()] = 1;
            } catch (NoSuchFieldError e) {
            }
            try {
                f347a[QueryRuleEnum.GE.ordinal()] = 2;
            } catch (NoSuchFieldError e2) {
            }
            try {
                f347a[QueryRuleEnum.LT.ordinal()] = 3;
            } catch (NoSuchFieldError e3) {
            }
            try {
                f347a[QueryRuleEnum.LE.ordinal()] = 4;
            } catch (NoSuchFieldError e4) {
            }
            try {
                f347a[QueryRuleEnum.NE.ordinal()] = 5;
            } catch (NoSuchFieldError e5) {
            }
            try {
                f347a[QueryRuleEnum.IN.ordinal()] = 6;
            } catch (NoSuchFieldError e6) {
            }
            try {
                f347a[QueryRuleEnum.LIKE.ordinal()] = 7;
            } catch (NoSuchFieldError e7) {
            }
            try {
                f347a[QueryRuleEnum.LEFT_LIKE.ordinal()] = 8;
            } catch (NoSuchFieldError e8) {
            }
            try {
                f347a[QueryRuleEnum.RIGHT_LIKE.ordinal()] = 9;
            } catch (NoSuchFieldError e9) {
            }
            try {
                f347a[QueryRuleEnum.EQ.ordinal()] = 10;
            } catch (NoSuchFieldError e10) {
            }
        }
    }

    /* renamed from: a */
    public static void m278a(String str, SysPermissionDataRuleModel sysPermissionDataRuleModel, String str2, String str3, StringBuffer stringBuffer) {
        QueryRuleEnum byValue = QueryRuleEnum.getByValue(sysPermissionDataRuleModel.getRuleConditions());
        String m276a = m276a(sysPermissionDataRuleModel.getRuleValue(), !OnlineDbHandler.m286a(str3), byValue);
        if (m276a == null || byValue == null) {
            return;
        }
        if ("ORACLE".equalsIgnoreCase(str) && "Date".equals(str3)) {
            String replace = m276a.replace(CgformUtil.f231C, "");
            m276a = replace.length() == 10 ? CgformUtil.m344b(replace) : CgformUtil.m378a(replace);
        }
        switch (C00131.f347a[byValue.ordinal()]) {
            case 1:
                stringBuffer.append(CgformUtil.f207e + str2 + CgformUtil.f218p + m276a);
                return;
            case 2:
                stringBuffer.append(CgformUtil.f207e + str2 + CgformUtil.f217o + m276a);
                return;
            case 3:
                stringBuffer.append(CgformUtil.f207e + str2 + CgformUtil.f220r + m276a);
                return;
            case AuthConstants.f111o /* 4 */:
                stringBuffer.append(CgformUtil.f207e + str2 + CgformUtil.f219q + m276a);
                return;
            case 5:
                stringBuffer.append(CgformUtil.f207e + str2 + " <> " + m276a);
                return;
            case 6:
                stringBuffer.append(CgformUtil.f207e + str2 + " IN " + m276a);
                return;
            case 7:
                stringBuffer.append(CgformUtil.f207e + str2 + " LIKE '%" + QueryGenerator.trimSingleQuote(m276a) + "%'");
                return;
            case 8:
                stringBuffer.append(CgformUtil.f207e + str2 + " LIKE '%" + QueryGenerator.trimSingleQuote(m276a) + CgformUtil.f231C);
                return;
            case 9:
                stringBuffer.append(CgformUtil.f207e + str2 + " LIKE '" + QueryGenerator.trimSingleQuote(m276a) + "%'");
                return;
            case 10:
                stringBuffer.append(CgformUtil.f207e + str2 + CgformUtil.f215m + m276a);
                return;
            default:
                f346a.info("--查询规则未匹配到---");
                return;
        }
    }

    /* renamed from: a */
    public static String m279a(String str, String str2) {
        if ("int".equals(str) || DataBaseConst.f577h.equals(str)) {
            return str2;
        }
        if ("date".equals(str)) {
            return CgformUtil.f231C + str2 + CgformUtil.f231C;
        }
        if ("SQLSERVER".equals(CgformUtil.getDatabseType())) {
            return "N'" + str2 + CgformUtil.f231C;
        }
        return CgformUtil.f231C + str2 + CgformUtil.f231C;
    }

    /* renamed from: a */
    private static String m276a(String str, boolean z, QueryRuleEnum queryRuleEnum) {
        if (queryRuleEnum == QueryRuleEnum.IN) {
            return m277a(str, z);
        }
        if (z) {
            return CgformUtil.f231C + QueryGenerator.converRuleValue(str) + CgformUtil.f231C;
        }
        return QueryGenerator.converRuleValue(str);
    }

    /* renamed from: a */
    private static String m277a(String str, boolean z) {
        if (str == null || str.length() == 0) {
            return "()";
        }
        String[] split = QueryGenerator.converRuleValue(str).split(CgformUtil.f233E);
        ArrayList arrayList = new ArrayList();
        for (String str2 : split) {
            if (str2 != null && str2.length() != 0) {
                if (z) {
                    arrayList.add(CgformUtil.f231C + str2 + CgformUtil.f231C);
                } else {
                    arrayList.add(str2);
                }
            }
        }
        return "(" + StringUtils.join(arrayList, CgformUtil.f233E) + ")";
    }
}
